Kruskal's Algorithm
Kruskal's algorithm is a <a href="https://www.wikiwhat.page/kavramlar/greedy%20algorithm">greedy algorithm</a> used to find the <a href="https://www.wikiwhat.page/kavramlar/minimum%20spanning%20tree">minimum spanning tree</a> (MST) for a weighted, undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized.
How it Works:
Initialization: Start with an empty forest of trees, where each vertex is a separate tree.
Edge Sorting: Sort all the edges of the graph in non-decreasing order of their weights.
Edge Iteration: Iterate through the sorted list of edges. For each edge:
union
operation.Termination: Continue iterating until all vertices are connected into a single tree. This tree is the minimum spanning tree.
Key Concepts:
Time Complexity:
The time complexity of Kruskal's algorithm is typically O(E log E) or O(E log V), where E is the number of edges and V is the number of vertices in the graph. This is primarily due to the sorting of the edges (O(E log E)) and the DSU operations (which can be made nearly constant time with appropriate optimizations like path compression and union by rank). Since E can be at most V<sup>2</sup>, log E = O(log V), so O(E log E) is often written as O(E log V).
Ne Demek sitesindeki bilgiler kullanıcılar vasıtasıyla veya otomatik oluşturulmuştur. Buradaki bilgilerin doğru olduğu garanti edilmez. Düzeltilmesi gereken bilgi olduğunu düşünüyorsanız bizimle iletişime geçiniz. Her türlü görüş, destek ve önerileriniz için iletisim@nedemek.page